<?php 
class Front_Print_Generic extends System_Db_Generic  {
	public function getPreauthId($policy_id){
		$db = Zend_Registry :: get("db");
		//$cmd_exec_ = "select dbo.FN_Preauth_GetID ('".$policy_id."') as preauth_id";
		//$statement = $db->prepare('select dbo.FN_Preauth_GenID () as preauth_id');
		//echo $cmd_exec_; exit(); 
		$statement = $db->prepare("select dbo.FN_Preauth_GetID ('".$policy_id."') as preauth_id");	
		$statement->execute();
		$results = $statement->fetchAll();
		
		return $results['0']['preauth_id'];
	}
	public function getPolicyById($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_member_queryByPolicyID '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['effective'] = getDateFormat2($results[$key]['effective']);
			$results[$key]['expiry'] = getDateFormat2($results[$key]['expiry']);
			$results[$key]['me_cover'] = number_format($results[$key]['me_cover'],2,'.',',');
			$results[$key]['mc_cover'] = number_format($results[$key]['mc_cover'],2,'.',',');
		}
		return $results['0'];
	}
	public function getPaInfo($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_policy_get_info '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0'];
	}
	public function getPaClaim($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_Claim_Get_PA_Claim '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['acc_date'] = getDateFormat2($results[$key]['acc_date']);
			//$results[$key]['paid'] = number_format($results[$key]['paid'],2,'.',',');
			$results[$key]['paid'] = number_format($results[$key]['paid'],2,'.',',');
		}
		return $results;
	}
	public function getPaClaimOpd($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_Claim_Get_HealthOPD_Claim '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['acc_date'] = getDateFormat2($results[$key]['acc_date']);
			//$results[$key]['paid'] = number_format($results[$key]['paid'],2,'.',',');
			$results[$key]['paid'] = $results[$key]['paid'];
		}
		return $results;
	}
	public function getErClaim($policy_id){
		if(!$policy_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_Claim_Get_ER_Claim '$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['acc_date'] = getDateFormat2($results[$key]['acc_date']);
			$results[$key]['paid'] = number_format($results[$key]['paid'],2,'.',',');
		}
		return $results;
	}
	public function getPlan2catByPlanId($plan_id,$policy_id){
		if(!$plan_id) return;
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.sp_elink_plan2cat_byplanid '$plan_id','$policy_id'";
		$statement = $db->prepare($cmd_exec);
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0'];
	}
	//--beerz
	public function updatePreauthImage($preauthId,$img_data){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "exec dbo.SP_elink_Common_SaveFile 'elink_PreAuth_trans','preauth_img','AND(#)PreAuth_ID=''$preauthId''','''$img_data'''";
		$statement = $db->prepare($cmd_exec);
		$results = $statement->execute();		
		return $results;
	}
	public function getPreauthImage($preauthId){
		$db = Zend_Registry :: get("db");
		$cmd_exec = "select preauth_img from elink_PreAuth_trans where PreAuth_ID = '$preauthId'";	
		$statement = $db->prepare($cmd_exec);	
		$statement->execute();
		$results = $statement->fetchAll();
		return $results['0'];
	}
	public function getDeducList($policy_id){
		$db = Zend_Registry :: get("db");
		$statement = $db->prepare("SELECT * FROM [dbo].[tf_getDeductibleUsed] (   null  ,null  ,null  ,null  ,null  ,'$policy_id'  ,null)");
		$statement->execute();
		$results = $statement->fetchAll();
		foreach ($results as $key=>$value){
			$results[$key]['dgroup'] = getDateFormat2($results[$key]['dgroup']);
			//$results[$key]['deduc'] = number_format($results[$key]['deduc'],2,'.',',');
		}
		return $results;
	}
	//--beerz
	
}
?>